package com.aizuda.boot.modules.business.contract.entity.vo;

import com.aizuda.boot.modules.business.approval.entity.vo.ApprovalNodeDetailDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

// ContractDTO.java
@Data
@Schema(description = "合同详情DTO")
public class ContractDTO {
    @Schema(description = "合同ID")
    private Integer id;
    @Schema(description = "合同流程ID")
    private Long processId;
    @Schema(description = "审批流程实例ID")
    private Long instanceId;
    @Schema(description = "合同类型ID")
    private Integer contractTypeId;
    @Schema(description = "合同类型")
    private List<String> contractTypeNames;
    @Schema(description = "合同模块列表")
    private List<ModuleDTO> modules;
    @Schema(description = "申请时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime applyDate;
    @Schema(description = "当前审批状态")
    private String currentStatus;
    @Schema(description = "系统租户键")
    private String sysTenantKey;
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;
    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedAt;
    @Schema(description = "主合同文件地址")
    private String mainContractFileUrl;
    @Schema(description = "主合同文件ID")
    private Integer mainContractFileId;
    @Schema(description = "主合同文件名称")
    private String mainContractFileName;
    @Schema(description = "申请人名称")
    private String applicantName;
    @Schema(description = "申请人昵称")
    private String applicantNickname;
    @Schema(description = "申请人头像地址")
    private String applicantAvatar;
    @Schema(description = "申请人部门")
    private String applicantDepartment;
    @Schema(description = "合同名称")
    private String contractName;
    @Schema(description = "合同编号")
    private String contractCode;
    @Schema(description = "合同经办人ID")
    private Long handlerId;
    @Schema(description = "合同经办人名称")
    private String handlerName;
    @Schema(description = "合同经办人部门")
    private String handlerDepartment;
    @Schema(description = "审批节点详情")
    private List<ApprovalNodeDetailDTO> approvalNodeDetails;
    @Schema(description = "合同字段列表")
    private List<ModuleDTO.FieldDTO> fields;

    @Schema(description = "法人实体详情列表（我方信息）")
    private List<LegalEntityDetailDTO> legalEntityDetails;

    @Schema(description = "交易方详情列表（对方信息）")
    private List<CounterpartyDetailDTO> counterpartyDetails;

    @Schema(description = "合同模版内容")
    private String content;

    @Schema(description = "到达时间（待我审批任务的创建时间）")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime arrivalTime;

    // ModuleDTO.java
    @Data
    @Schema(description = "合同模块DTO")

    public static class ModuleDTO {
        @Schema(description = "模块ID")
        private Integer id;

        @Schema(description = "模块名称")
        private String moduleName;

        @Schema(description = "模块描述")
        private String moduleDescription;

        @Schema(description = "模块排序")
        private Integer moduleOrder;

        @Schema(description = "字段列表")
        private List<FieldDTO> fields;

        // FieldDTO.java
        @Data
        @Schema(description = "合同字段DTO")
        public static class FieldDTO {
            @Schema(description = "字段ID")
            private Long id;

            @Schema(description = "字段名称")
            private String fieldName;

            @Schema(description = "字段编码")
            private String code;

            @Schema(description = "字段类型")
            private String fieldType;

            @Schema(description = "字段值")
            private String fieldValue;

            @Schema(description = "字段选项")
            private Map<String, Object> fieldOptions;

            @Schema(description = "是否必填")
            private Boolean isRequired;

            @Schema(description = "子字段列表（当字段类型为GROUP时）")
            private List<FieldDTO> children;

            @Schema(description = "字段描述信息（根据字段类型解析后的详细信息）")
            private List<Map<String, Object>> fieldDesc;
        }
    }
}



